#!/usr/bin/env python
import pickle
import sys
import os
import re
import anydbm
import urllib2

if "UBIQIS_ROOT" not in os.environ:
    os.environ["UBIQIS_ROOT"] = "/mnt/ubiqis"

import uroot.config

# default registrar
registrar = uroot.config.REGISTRARS[0] #"http://registrar.ubiqis.com"

# perform the actual search
for a in sys.argv[1:]:
    url = registrar + "/lookup?key="+urllib2.quote(a)+"&raw=yes&wait=yes"
    data = urllib2.urlopen(url).read()
    result = pickle.loads(data)
    if result == None:
        continue
    for line in result:
        print str(line[0])
